# 导入 efinance 库
import efinance as ef
import pandas as pd


# 股票代码
stock_code = '600519'
# 获取股票的一些基本信息(返回 pandas.Series)
#series = ef.stock.get_base_info(stock_code)
#print(series)

# 获取股票日 K 线数据
df = ef.stock.get_quote_history(stock_code)
#将df0按code进行排序
df = df.sort_index(axis=0, ascending=True)
#将 涨跌幅（changepercent)<4% 和 0.8%<换手率(turnoverratio)<3% 的保留下来
df = df[(df['涨跌幅']<4) & (0.8<df['换手率'])&(df['换手率']<3)]
print(df)
print(len(df))

